<%--
  Created by IntelliJ IDEA.
  User: 吴超
  Date: 2022/4/26
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        span{
            color: red;
        }
    </style>
    <script src="../js/jquery.js"></script>
</head>
<body>
<table border="3">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>sex</th>
        <th>标志</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${list}" var="xjj" varStatus="stat">
        <tr <c:if test="${stat.index%2!=0}">style="background-color: green" </c:if> >
            <td>${xjj.getId()}</td>
            <td>${xjj.getName()}</td>
            <td>${xjj.getSex()}</td>
            <td>${xjj.getFlage()==0?"上架":"下架"}</td>
            <td>   <a href="${pageContext.request.contextPath}/ServletNC?op=delete&id=${xjj.getId()}"><input type="button" class="delete" value="删除"> </a>

                <a href="${pageContext.request.contextPath}/ServletNC?op=update1&id=${xjj.getId()}">修改</a>
                <input type="button" class="delete143" value="异步删除">
            </td>
            <td>  <input type="button" class="delete14" value="异步删除14"></td>
        </tr>
    </c:forEach>
</table>  <a href="demonc/add.jsp">增加</a>
<span>${delete1}</span>
<span>${delete2}</span>
<span>${add1}</span>
<span>${add2}</span>
<span>${update11}</span>
<span>${update1}</span>
<span>${update2}</span>
<span id="sp">11111</span>
<script>
    $(".delete14").click(function () {
        alert("111");
        $(this).css("background-color","red");
    });

    $(".delete143").click(function () {
        alert("uuu");
        var id=$(".delete143").parents("tr").children().eq(0).html();
        alert(id);
        $.get(
            "${pageContext.request.contextPath}/ServletNC?op=delete1&id="+id
            ,function (data) {
                if(data.trim()=="y"){
                    $(".delete143").parents("tr").remove();
                }else{

                }
            }
        );


    });



    $("#sp").css("background-color","red");

    /*  $(".delete").click(function () {
          if(confirm("确定删除吗？")){
              return true;
          }else{
              return  false;
          }
      });*/
</script>
</body>
</html>
